package com.sgb.kjwl.viewmodel.pick;

import com.sgb.kjwl.api.APIManager;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.util.PickSelectEntity;
import com.sgb.kjwl.repository.PickRepertory;
import com.sgb.kjwl.view.ui.activity.self.pick.SelfPickListActivity4;
import com.swgk.core.base.BaseViewModel;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.dialog.DialogHelper;

import java.util.List;

public class SelfPickList4Model extends BaseViewModel {

    private SelfPickListActivity4 activity;
    private PickRepertory repertory;

    public SelfPickList4Model(SelfPickListActivity4 activity, PickRepertory repertory) {
        this.activity = activity;
        this.repertory = repertory;
    }

    public void groupBuyClassList() {
        DialogHelper.showProgressDialog(activity, null, "加载中...", 0, true, null).setCanceledOnTouchOutside(false);
        APIManager.getInstance().getCentralizedMiningAPI().groupBuyClassList().enqueue(new ICallBack<BaseEntity<List<PickSelectEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<PickSelectEntity>> data) {
                if (data == null || data.getState() == null) {
                    activity.showEmpty();
                    return;
                }

                if (data.getState().equals(APIManager.RESPONSE_OK)) {
                    activity.updateViews(data.getData());
                } else {
                    activity.showEmpty();
                }
            }
        });
    }

}
